import './assets/main.css'

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper'


// 使用乾坤渲染
renderWithQiankun({
  // 挂载时
  mount (props) {
    console.log('mount')
    // 进入子应用。加载时，让主应用的组件隐藏
    document.querySelector('.wscn-http404-container').style.display = 'none'
    render(props)
  },
  bootstrap () {
    console.log('bootstrap')
  },
  unmount (props) {
    // 退出子应用时，保证属性样式为白色
    document.getElementById('app').style.backgroundColor = '#fff'          
    //退出子应用，让主应用的组件显示
     document.querySelector('.wscn-http404-container').style.display = 'block'
    console.log('unmount', props)
  },
})

if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  render({})
}


function render (props = {}) {
  const { container } = props
  const app = createApp(App)
  app.use(router)
  app.mount(container ? container.querySelector("#app") : "#app")
}
// const app = createApp(App)
// //将router对象和 app对象关联起来
// app.use(router)

// app.mount('#app')
